function TreeNode(val) {
    this.val = val;
    this.left = this.right = null
}
/**
 * @param {TreeNode} root
 * @return {number[]}
 */
var levelOrder = function(root) {
    // 边界条件
    if (root == null) return []
    // 存放最终的结果
    let result = []
    // 队列
    let queue = []
    queue.push(root)
    // return queue

    while (queue.length != 0) {
        // if (root == null) return
        let treeNode = queue.shift()
        result.push(treeNode.val)
        // return result
        if (treeNode.left != null) queue.push(treeNode.left)
        if (treeNode.right != null) queue.push(treeNode.right)
    }
    return result
};
let root = new TreeNode(3)
root.left = new TreeNode(9)
root.right = new TreeNode(20)
root.right.left = new TreeNode(15)
root.right.right = new TreeNode(7)
console.log(levelOrder(root))